package org.huang;

import sun.reflect.ReflectionFactory;

import java.lang.reflect.Field;

/**
 * @author hdu_huang
 * @since 2024/1/3 10:26
 */
public class Main {

    //springboot2.3x 可以优雅停止 tomcat等web容器
    public static void main(String[] args) throws Exception{

        //Java21 依然可用
        ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory();


        System.out.println(reflectionFactory);

        //java17由 jdk.internal.misc -> jdk.internal.access , 必须编译加--add-exports   运行加--add-opens
        //JavaLangAccess sharedSecrets = SharedSecrets.getJavaLangAccess();
        //jdk.internal.misc.Unsafe theInternalUnsafe = jdk.internal.misc.Unsafe.getUnsafe();

        //jdk.internal.misc
        //只反射使用，则运行参数--add-opens就可以
        //Class<?> unsafeClass = Class.forName("jdk.internal.misc.Unsafe");
        //Field theUnsafe = unsafeClass.getDeclaredField("theUnsafe");
        //theUnsafe.setAccessible(true);
        //Object internalUnsafe = theUnsafe.get(null);

        //java21
        StringBuilder sb = new StringBuilder();
        sb.repeat("*", 10);

        System.out.println(sb.toString());

        System.out.println("Hello world!");

    }
}